import Vue from 'vue';
import Vuex from 'vuex';
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    token: sessionStorage.getItem("token"),
    merchant: JSON.parse(sessionStorage.getItem("merchant"))
  },
  mutations: {
    // set
    SET_TOKENN: (state, token) => {
      state.token = token
      sessionStorage.setItem("token", token)
    },
    SET_MERCHANT: (state, merchant) => {
      state.merchant = merchant
      sessionStorage.setItem("merchant", JSON.stringify(merchant))
    },
    REMOVE_INFO : (state) => {
      state.token = ''
      state.merchant = {}
      sessionStorage.setItem("token", '')
      sessionStorage.setItem("merchant", JSON.stringify(''))
    }
  },
  getters: {

  },
  actions: {
  },
  modules: {
  }
})
